package model.exception;

/**
 * A general exception containing common functionality
 * for all exceptions in GEDIVA program.
 *
 * @author Robert C. Duvall
 * modified by Zach Michaelov
 */
@SuppressWarnings("serial")
public abstract class GedivaException extends RuntimeException {
    private final Throwable myCause;

    /**
     * Create exception with given message.
     *
     * @param message explanation of problem
     * @param values details of problem
     */
    public GedivaException(String message, Object... values) {
        super(String.format(message, values));
        myCause = this;
    }

    /**
     * Create exception with given message.
     *
     * @param cause original cause of this exception
     * @param message explanation of problem
     * @param values details of problem
     */
    public GedivaException(Throwable cause, String message, Object... values) {
        super(String.format(message, values) + "\n" + cause.getMessage());
        myCause = cause;
    }

    /*
     * @see java.lang.Throwable#getCause()
     */
    @Override
    public Throwable getCause () {
        return myCause;
    }
}

